package com.azt.provider.impl;

import com.azt.api.pojo.SignupMember;
import com.azt.api.pojo.req.SignUpMemberReq;
import com.azt.api.service.SignupMemberService;
import com.azt.model.page.Pagination;
import com.azt.provider.mapper.SignupMemberMapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service
@Transactional
public class SignupMemberServiceImpl implements SignupMemberService {

	@Autowired
	private SignupMemberMapper signupMemberMapper;

	@Override
	public Pagination signupMemberList(int pageno, int pagesize, Map<String, String> params) {
		Page<Object> startPage = PageHelper.startPage(pageno, pagesize);
		//List<SignupMember> SignupMemberList =signupMemberMapper.selectAll();
		List<Map<String, String>> SignupMemberList = signupMemberMapper.selectSignupMemberList(params);
		Pagination p = new Pagination(startPage, SignupMemberList);
		p.setList(SignupMemberList);
		return p;
	}

	@Override
	public void save(SignUpMemberReq req) {
		SignupMember member = new SignupMember();
		BeanUtils.copyProperties(req, member);
		signupMemberMapper.insert(member);
	}
}
	


